package com.qianbao.qianbaobusiness.ui.cashier;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.baseandroid.config.Constant;
import com.baseandroid.utils.MoneyUtil;
import com.baseandroid.utils.TimeUtils;
import com.qianbao.qianbaobusiness.R;
import com.qianbao.qianbaobusiness.json.AboutSettlementBean;

import java.util.List;

public class DataSettlementAdapter extends BaseAdapter {

    private LayoutInflater mInflater;
    private List<AboutSettlementBean> list;
    private Context mContext;

    public DataSettlementAdapter(Context context, List<AboutSettlementBean> list) {
        this.mInflater = LayoutInflater.from(context);
        this.list = list;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.item_date_settlement, null);
            holder.tv_date_settlement_time = (TextView) convertView.findViewById(R.id.tv_date_settlement_time);
            holder.tv_date_settlement_money = (TextView) convertView.findViewById(R.id.tv_date_settlement_money);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        String time1 = list.get(position).getChkAccountDate();
        time1 = TimeUtils.getDate(time1, Constant.DATE_YYYYMMDD, Constant.DATE_YYYY_MM_DD);
        holder.tv_date_settlement_time.setText(time1);
        String cardMoney = Double.parseDouble(list.get(position)
                .getSettlementAmtTotal()) / 100 + "";
        cardMoney = MoneyUtil.getMoneyFormat(cardMoney);
        holder.tv_date_settlement_money.setText(mContext.getResources()
                .getString(R.string.rmb) + cardMoney);
        return convertView;
    }

    class ViewHolder {
        TextView tv_date_settlement_time;
        TextView tv_date_settlement_money;
    }

}
